# -*- coding: utf-8 -*-
"""
 @Time    : 2021/2/2 下午3:35
 @Author  : tgy
 
"""


class Set:
    ...

    def __init__(self, val):
        ...
        self.data = []
        self.concat(val)

    def interset(self, other):
        ...
        inter_data = []
        for va in self.data:
            if va in other.data:
                ...
                inter_data.append(va)

        return Set(inter_data)

    def union(self, other):
        ...
        union_data = self.data[:]
        for va in other.data:
            ...
            if va not in union_data:
                union_data.append(va)
        return Set(union_data)

    def __iter__(self):
        return iter(self.data)

    def concat(self, val):
        ...
        if not val:
            return
        for va in val:
            ...
            if va not in self.data:
                self.data.append(va)

    def __repr__(self):
        return f'{self.__class__.__name__}:{self.data}'

    def __len__(self):
        return len(self.data)

    def __and__(self, other):
        return self.interset(other)

    def __or__(self, other):
        return self.union(other)

    def __getitem__(self, item):
        return self.data[item]


if __name__ == '__main__':
    ...
    set1 = Set([1,2,2,3])
    print(set)
    set2 = Set([1,3,4])
    print(set1 | set2)
    for va in (set1 | set2):
        print(va)